package com.ubi.core.framework.job;

import org.springframework.scheduling.config.CronTask;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

/**
 * @author raymond
 */
public class JobRegistry {

    private final ScheduledTaskRegistrar taskRegistrar;

    public JobRegistry(ScheduledTaskRegistrar scheduledTaskRegistrar) {
        this.taskRegistrar = scheduledTaskRegistrar;
    }

    public void registryCronJob(Job job, String cronExpression) {
        taskRegistrar.addCronTask(new CronTask(job, cronExpression));
    }

}
